﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class YinSi : MonoBehaviour
{
    // Start is called before the first frame update
    private void Awake()
    {
        transform.Find("splansh/著作权人").GetComponent<Text>().text = AdManager.Owner;
        transform.Find("splansh/登记号").GetComponent<Text>().text = AdManager.License;
        transform.Find("splansh/适龄").Find(AdManager.AgeLimit.ToString()).gameObject.SetActive(true);
        if (PlayerPrefs.GetInt("YinSi") == 1) Accept();
    }

    // Update is called once per frame
    void Update()
    {

    }

    void Next()
    {
        SceneManager.LoadScene(1);
    }

    public void Accept()
    {
        if (PlayerPrefs.GetInt("YinSi") == 1)
        {
            transform.GetChild(1).gameObject.SetActive(false);
        }
        else
        {
            transform.GetChild(1).gameObject.GetComponent<FadeEffect>().FadeOut();
        }
        PlayerPrefs.SetInt("YinSi", 1);
        Invoke("Next", 2);
    }

    public void Refuse()
    {
        AdManager.Instance.Quit();
    }
}
